home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 Christmas / macformat-045.iso / Shareware Plus / Developers / NGL1.5.0E(fat)DEMO / Font Sample(PPC) / Font_Sample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-19  |  2.2 KB  |  94 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                     N_Font sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include    "N_Library.h"
  8.  
  9. WindowPtr     CreateWindow         (Str255 name);
  10.  
  11.  
  12. #define        WindowSizeX        640
  13. #define        WindowSizeY        480
  14.  
  15. short        NewWindowX;
  16. short        NewWindowY;
  17.  
  18. short        Data_Rsrc = 0;
  19.  
  20. WindowPtr    window;
  21.  
  22.  
  23. //counter
  24. long        counter1 = 123456;
  25. long        counter2 = 99999;
  26.  
  27. short        x = -100;
  28. short        x2 = 640;
  29.  
  30. void main(void)
  31. {
  32.     ToolboxInit();
  33.     ColorCheck();
  34.     HideCursor();
  35.     window = CreateWindow("\pN Game Library <Font Sample>");
  36.     N_Window_Set(window,NewWindowX,NewWindowY,WindowSizeX,WindowSizeY);    //set up window
  37.     Open_Resource_File(128,1,&Data_Rsrc);
  38.     N_Sp_Make(640,480);                                                //set up for sprites
  39.     N_Cel_Make(65536);                                                //set up for cel
  40.     N_Font_Init();
  41.     N_Sprite_Set(129,0,14,24,1,11,1,0);                                    //set sprites
  42.     N_Sprite_Set(130,11,12,16,1,13,4,0);
  43.  
  44.     N_Font_Set(0,0,0,0x80000000,0);                                        //set fonts
  45.     N_Font_Set(1,0x80000000+11,0,0x80000000+26+11,0x80000000+37+11);
  46.  
  47.     N_Pict_Draw(128,0,0,(GrafPtr)SP_off,true);                                //draw background
  48.     Close_Resource_File(&Data_Rsrc);
  49.  
  50.     do
  51.     {
  52.         N_Num_Put(counter1,x,80,8,16,0,1,0);                                    //(x,80)ÅAspace16,8segments,fontset0,cel plane  0-
  53.         N_Num_Put(counter2,x,138,8,14,1,1,24);                                //(x,160)ÅAspace14,8segments,fontset1,cel plane  24-
  54.         N_Font_Put("\pN GAME LIBRARY SAMPLE PROGRAM!",x2,180,14,1,1,30);
  55.         counter1++;                                                        //updates counters
  56.         counter2-=64;
  57.         if (counter1 >= 99999999) counter1 = 0;
  58.         if (counter2 <= 0) counter2 = 99999;
  59.     
  60.         x = x+1;                                                            //move
  61.         if (x >= 640) x=-100;
  62.  
  63.         x2-=2;
  64.         if (x2 <= -500) x2=640;
  65.  
  66.     
  67.         N_Cel_Loop(0,0);
  68.     }
  69.     while (!Button());
  70.     ShowCursor();
  71.     ColorRevert();
  72. }
  73.  
  74.  
  75. WindowPtr CreateWindow (Str255 name)
  76. {
  77.     short        centerX,centerY;
  78.     short        windowWidth,windowHeight;
  79.  
  80.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  81.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  82.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  83.     SetWTitle(window,name);
  84.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  85.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  86.     ShowWindow(window);
  87.     SetPort((GrafPtr)window );
  88.     return (WindowPtr)window;
  89. }
  90.     
  91.  
  92.  
  93.  
  94.